<%@ page import="com.touzi.constants.MobileCons" %>
<%@ page import="com.touzi.utils.MyHTTPUtils" %>
<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="org.apache.ibatis.session.SqlSessionFactory" %>
<%@ page import="com.touzi.constants.DbCons" %>
<%@ page import="com.touzi.mapper.UserMapper" %>
<%@ page import="com.touzi.beans.dbs.users.User" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.touzi.mapper.TongjiMapper" %><%--
  Created by IntelliJ IDEA.
  User: w7851
  Date: 2018/5/22
  Time: 10:12
  To change this template use File | Settings | File Templates.
  查看一名用户的具体信息
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%

    String userphone = request.getParameter("phone");

    SqlSession sqlSession = ((SqlSessionFactory) application.getAttribute(DbCons.DB_FACTORY)).openSession();
    UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
    TongjiMapper tongjiMapper = sqlSession.getMapper(TongjiMapper.class);
    User user = userMapper.findUserByDianhua(userphone).get(0);

    List<User> yiji = userMapper.findYijXiashuByID(user.id);
    List<User> erji = userMapper.findErjXiashuByID(user.id);
    List<User> sanji = userMapper.findSanjXiashuByID(user.id);
    List<User> siji = userMapper.findSijXiashuByID(user.id);
    List<User> wuji = userMapper.findWujXiashuByID(user.id);
    List<User> liuji = userMapper.findLiujXiashuByID(user.id);
    List<User> qiji = userMapper.findQijXiashuByID(user.id);
    List<User> baji = userMapper.findBajXiashuByID(user.id);
    List<User> jiuji = userMapper.findJiujXiashuByID(user.id);
    List<User> shiji = userMapper.findShijXiashuByID(user.id);
    List<User> shiyiji = userMapper.findShiYijXiashuByID(user.id);
    List<User> shierji = userMapper.findShiErjXiashuByID(user.id);
    List<User> shisanji = userMapper.findShiSanjXiashuByID(user.id);

    List<User> all = new ArrayList<>();
    all.addAll(yiji);
    all.addAll(erji);
    all.addAll(sanji);
    all.addAll(siji);
    all.addAll(wuji);
    all.addAll(liuji);
    all.addAll(qiji);
    all.addAll(baji);
    all.addAll(jiuji);
    all.addAll(shiji);
    all.addAll(shiyiji);
    all.addAll(shierji);
    all.addAll(shisanji);
    for (User u : all) {
        if (u.cousumed.equals("yes")) {
            u.cousumed = "已消费";
        } else {
            u.cousumed = "未消费";
        }
    }
    String leijixiaofei = tongjiMapper.aUserLeijiXFByID(user.id);
    //当日有效直推
    int youxiaozhituiren=tongjiMapper.getTodayYXTJ(user.id);
    String leijitixian = tongjiMapper.aUserLeijiTXByID(user.id);
    //今日业绩
    String jinriyeji = tongjiMapper.getAUserYeji(user.id);
    //所有的团队业绩
    String allTDYJ=tongjiMapper.getAUserAllTDYJ(user.id);
    sqlSession.close();

    request.setAttribute("yiji", yiji);
    request.setAttribute("erji", erji);
    request.setAttribute("sanji", sanji);
    request.setAttribute("siji", siji);
    request.setAttribute("wuji", wuji);
    request.setAttribute("liuji", liuji);
    request.setAttribute("qiji", qiji);
    request.setAttribute("baji", baji);
    request.setAttribute("jiuji", jiuji);
    request.setAttribute("shiji", shiji);
    request.setAttribute("shiyiji", shiyiji);
    request.setAttribute("shierji", shierji);
    request.setAttribute("shisanji", shisanji);
    request.setAttribute("user", user);
%>
<html>
<head>
    <title>查看</title>
    <meta charset="utf-8">
    <style>
        #content {
            width: 400px;
            margin: auto;
        }
    </style>
</head>
<body>
<div id="content">
    <p>用户(${user.id})的具体信息</p>
    <p>累计消费:<%=leijixiaofei%>  累计提款:<%=leijitixian%></p>
    <p>累计业绩:<%=allTDYJ%> 今日业绩:<%=jinriyeji%>  今日有效直推:<%=youxiaozhituiren%></p>
    <hr>
    <p>一级团队</p>
    <c:forEach var="item" items="${yiji}">
        <p>✪${item.id}←${item.tuijianren} ${item.zhuceshijian} ${item.cousumed}</p>
    </c:forEach>
    <hr>
    <p>二级团队</p>
    <c:forEach var="item" items="${erji}">
        <p>✪${item.id}←${item.tuijianren} ${item.zhuceshijian} ${item.cousumed}</p>
    </c:forEach>
    <hr>
    <p>三级团队</p>
    <c:forEach var="item" items="${sanji}">
        <p>✪${item.id}←${item.tuijianren} ${item.zhuceshijian} ${item.cousumed}</p>
    </c:forEach>
    <hr>
    <p>四级团队</p>
    <c:forEach var="item" items="${siji}">
        <p>✪${item.id}←${item.tuijianren} ${item.zhuceshijian} ${item.cousumed}</p>
    </c:forEach>
    <hr>
    <p>五级团队</p>
    <c:forEach var="item" items="${wuji}">
        <p>✪${item.id}←${item.tuijianren} ${item.zhuceshijian} ${item.cousumed}</p>
    </c:forEach>
    <hr>
    <p>六级团队</p>
    <c:forEach var="item" items="${liuji}">
        <p>✪${item.id}←${item.tuijianren} ${item.zhuceshijian} ${item.cousumed}</p>
    </c:forEach>
    <hr>
    <p>七级团队</p>
    <c:forEach var="item" items="${qiji}">
        <p>✪${item.id}←${item.tuijianren} ${item.zhuceshijian} ${item.cousumed}</p>
    </c:forEach>
    <hr>
    <p>八级团队</p>
    <c:forEach var="item" items="${baji}">
        <p>✪${item.id}←${item.tuijianren} ${item.zhuceshijian} ${item.cousumed}</p>
    </c:forEach>
    <hr>
    <p>九级团队</p>
    <c:forEach var="item" items="${jiuji}">
        <p>✪${item.id}←${item.tuijianren} ${item.zhuceshijian} ${item.cousumed}</p>
    </c:forEach>
    <hr>
    <p>十级团队</p>
    <c:forEach var="item" items="${shiji}">
        <p>✪${item.id}←${item.tuijianren} ${item.zhuceshijian} ${item.cousumed}</p>
    </c:forEach>
    <hr>
    <p>十一级团队</p>
    <c:forEach var="item" items="${shiyiji}">
        <p>✪${item.id}←${item.tuijianren} ${item.zhuceshijian} ${item.cousumed}</p>
    </c:forEach>
    <hr>
    <p>十二级团队</p>
    <c:forEach var="item" items="${shierji}">
        <p>✪${item.id}←${item.tuijianren} ${item.zhuceshijian} ${item.cousumed}</p>
    </c:forEach>
    <hr>
    <p>十三级团队</p>
    <c:forEach var="item" items="${shisanji}">
        <p>✪${item.id}←${item.tuijianren} ${item.zhuceshijian} ${item.cousumed}</p>
    </c:forEach>
</div>
</body>
</html>
